<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="../inc/TagLibs.jsp"%>
<c:set var="pageTitle" value="入库单" />
<%@ include file="../inc/Title.jsp"%>
<head>
<link href="/calendar/dhtmlgoodies_calendar/dhtmlgoodies_calendar.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="/css/BillEdit.css" />
<script src="/js/popup_ext.js"></script>
<script src="/calendar/dhtmlgoodies_calendar/dhtmlgoodies_calendar.js"></script>
<script language="javascript">
	function doSave(flag){
		document.getElementById("buttonDiv").style.display="none";
		document.getElementById("waitDiv").style.display="";
		document.getElementById("continue_flag").value=flag;
		<c:if test="${currentUser.user.userType==1 || fn:indexOf(currentUser.privs,';IN_EXAM;')!=-1}">
			ShowConfirm('确认框','是否同时审核？',340,80,"doSaveCallBack()");
		</c:if>
		<c:if test="${currentUser.user.userType!=1 && fn:indexOf(currentUser.privs,';IN_EXAM;')==-1}">
			frm.submit();
		</c:if>
	}
	function doSaveCallBack(){
		if(popRetVal!=null){
			document.getElementById("examine").value="1";
		}
		frm.submit();
	}
	function doReorder(id){
		window.location="InBillNew.ihtm?alert_type=${alertType}&data_type=COPY&template_id="+id;
	}
	function doCancel(){
		if(window.opener){
			window.close();
		}else{
			parent.ClosePop();
		}
	}
	function elementOnChnage(){
		checkItemChange(this.getAttribute("index"),this.id);
	}
	function productOnChnage(){
		checkProductChange(this.getAttribute("index"));
	}
	function inputOnMouseOver(){
		this.title=this.value;
	}
	function checkProductChange(index){
		if(window.event.keyCode==13){
			selectProduct(index);
		}
	}
	function buttonOnClick(){
		selectProduct(this.getAttribute("index"));
	}
	function selectProduct(index){
		var url="/base/ProductMainForSelect.ihtm";
		ShowIframe("选择材料",url,900,500,"selectProductCallBack("+index+")");
	}
	function selectProductCallBack(index){
		if(popRetVal!=null){
			document.getElementById("product_id_"+index).value=popRetVal[0];
			document.getElementById("product_code_"+index).value=popRetVal[1];
			document.getElementById("product_name_"+index).value=popRetVal[2];
			document.getElementById("product_unit_"+index).value=popRetVal[3];
			checkItemChange(index);
		}
	}
	function doMultiSelect(){
		var url="/base/ProductMainForSelect.ihtm?type=MULTI";
		ShowIframe("选择材料",url,900,500,"doMultiSelectCallBack()");
	}
	function doMultiSelectCallBack(){
		if(popRetVal!=null){
			for(i=0;i<popRetVal.length;i++){
				var newIndex=doItemAdd();
				document.getElementById("product_id_"+newIndex).value=popRetVal[i][0];
				document.getElementById("product_code_"+newIndex).value=popRetVal[i][1];
				document.getElementById("product_name_"+newIndex).value=popRetVal[i][2];
				document.getElementById("product_unit_"+newIndex).value=popRetVal[i][3];
				checkItemChange(newIndex);
			}
		}
	}
	function doItemAdd(){
		var tbl=document.getElementById("itemRowTbl");
		var itemNum=document.getElementById("item_num").value-0;

		var tr=document.createElement("tr");
		tr.setAttribute("id","itemTr"+itemNum);
		
		var td;
		var input;

		td=document.createElement("td");
		input=document.createElement("input");
		input.setAttribute("type","text");
		input.style.width="80px";
		input.setAttribute("index",itemNum);
		input.setAttribute("name","product_code_"+itemNum);
		input.setAttribute("id","product_code_"+itemNum);
		input.setAttribute("readOnly",true);
		input.setAttribute("className","TextBox readonly");
		input.setAttribute("class","TextBox readonly");
		td.appendChild(input);
		tr.appendChild(td);
		
		td=document.createElement("td");
		input=document.createElement("input");
		input.setAttribute("type","text");
		input.style.width="160px";
		input.setAttribute("index",itemNum);
		input.setAttribute("name","product_name_"+itemNum);
		input.setAttribute("id","product_name_"+itemNum);
		input.setAttribute("readOnly",true);
		input.setAttribute("className","TextBox readonly");
		input.setAttribute("class","TextBox readonly");
		input.onmouseover=inputOnMouseOver;
		td.appendChild(input);
		
		td.appendChild(document.createTextNode(" "));
		input=document.createElement("img");
		input.setAttribute("src","/images/icon_add.gif");
		input.setAttribute("index",itemNum);
		input.style.cursor="pointer";
		input.onclick=buttonOnClick;
		td.appendChild(input);
		
		input=document.createElement("input");
		input.setAttribute("type","hidden");
		input.setAttribute("name","product_id_"+itemNum);
		input.setAttribute("id","product_id_"+itemNum);
		input.setAttribute("value","0");
		td.appendChild(input);
		
		tr.appendChild(td);
		
		td=document.createElement("td");
		input=document.createElement("input");
		input.setAttribute("type","text");
		input.style.width="40px";
		input.setAttribute("index",itemNum);
		input.setAttribute("name","product_unit_"+itemNum);
		input.setAttribute("id","product_unit_"+itemNum);
		input.setAttribute("readOnly",true);
		input.setAttribute("className","TextBox readonly");
		input.setAttribute("class","TextBox readonly");
		td.appendChild(input);
		tr.appendChild(td);
		
		td=document.createElement("td");
		input=document.createElement("input");
		input.setAttribute("type","text");
		input.style.cssText="text-align:right";
		input.style.width="50px";
		input.setAttribute("maxLength","10");
		input.setAttribute("index",itemNum);
		input.setAttribute("name","amount_"+itemNum);
		input.setAttribute("id","amount_"+itemNum);
		input.setAttribute("value","");
		input.setAttribute("className","TextBox");
		input.setAttribute("class","TextBox");
		input.onchange=elementOnChnage;
		td.appendChild(input);
		tr.appendChild(td);
		
		td=document.createElement("td");
		input=document.createElement("input");
		input.setAttribute("type","text");
		input.style.cssText="text-align:right";
		input.style.width="50px";
		input.setAttribute("maxLength","10");
		input.setAttribute("index",itemNum);
		input.setAttribute("name","unit_price_"+itemNum);
		input.setAttribute("id","unit_price_"+itemNum);
		input.setAttribute("value","");
		input.setAttribute("className","TextBox");
		input.setAttribute("class","TextBox");
		input.onchange=elementOnChnage;
		td.appendChild(input);
		tr.appendChild(td);
		
		td=document.createElement("td");
		input=document.createElement("input");
		input.setAttribute("type","text");
		input.style.cssText="text-align:right";
		input.style.width="50px";
		input.setAttribute("maxLength","10");
		input.setAttribute("index",itemNum);
		input.setAttribute("name","cost_"+itemNum);
		input.setAttribute("id","cost_"+itemNum);
		input.setAttribute("value","0");
		input.setAttribute("readOnly",true);
		input.setAttribute("className","TextBox readonly");
		input.setAttribute("class","TextBox readonly");
		td.appendChild(input);
		tr.appendChild(td);
		
		td=document.createElement("td");
		input=document.createElement("input");
		input.setAttribute("type","text");
		input.style.width="150px";
		input.setAttribute("maxLength","200");
		input.setAttribute("index",itemNum);
		input.setAttribute("name","mark_"+itemNum);
		input.setAttribute("id","mark_"+itemNum);
		input.setAttribute("value","");
		input.setAttribute("className","TextBox");
		input.setAttribute("class","TextBox");
		input.onchange=elementOnChnage;
		td.appendChild(input);
		tr.appendChild(td);
		
		td=document.createElement("td");
		var delLink=document.createElement("a");
		delLink.setAttribute("href","javascript:doItemDelete("+itemNum+");");
		delLink.appendChild(document.createTextNode("删除"));
		td.appendChild(delLink);
		
		input=document.createElement("input");
		input.setAttribute("type","hidden");
		input.setAttribute("name","status_"+itemNum);
		input.setAttribute("id","status_"+itemNum);
		input.setAttribute("value","UNCHANGE");
		td.appendChild(input);
		
		input=document.createElement("input");
		input.setAttribute("type","hidden");
		input.setAttribute("name","id_"+itemNum);
		input.setAttribute("id","id_"+itemNum);
		input.setAttribute("value","0");
		td.appendChild(input);
		tr.appendChild(td);

		tbl.appendChild(tr);
		document.getElementById("item_num").value=itemNum+1;
		
		resizePopwin();
		
		return itemNum;//当前行的index
	}
	function doItemDelete(index){
		ShowConfirm('确认框','确定删除吗？',340,80,"doItemDeleteCallBack("+index+")");
	}
	function doItemDeleteCallBack(index){
		if(popRetVal!=null){
			document.getElementById("itemTr"+index).style.display="none";
			document.getElementById("status_"+index).value="DELETE";
			doCount();
			
			resizePopwin();
		}
	}
	function checkItemChange(index,id){
		if(document.getElementById("id_"+index).value=="" || document.getElementById("id_"+index).value=="0"){
			document.getElementById("status_"+index).value="NEW";
		}else{
			document.getElementById("status_"+index).value="EDIT";
		}
		
		if(document.getElementById("cost_"+index)!=null){
			var itemAmount=document.getElementById("amount_"+index).value;
			var itemUnitPrice=document.getElementById("unit_price_"+index).value;
			var itemCost;
			
			//金额
			if(!isNaN(itemAmount) && !isNaN(itemUnitPrice)){
				itemCost=accMul(itemAmount,itemUnitPrice);
				document.getElementById("cost_"+index).value=parseScale(itemCost,2);
			}
		}
		
		doCount();
	}
	
	function doCount(){
		var itemNum=document.getElementById("item_num").value-0;
		var itemCost;
		var itemAmount;
		var costTotal=0;
		var amountTotal=0;
		for(var i=0;i<itemNum;i++){
			if(document.getElementById("status_"+i).value!="DELETE"){
				if(document.getElementById("cost_"+i)!=null){
					itemCost=document.getElementById("cost_"+i).value;
					if(!isNaN(itemCost)){
						costTotal=addMul(costTotal,itemCost);
					}
				}
				if(document.getElementById("amount_"+i)!=null){
					itemAmount=document.getElementById("amount_"+i).value;
					if(!isNaN(itemAmount)){
						amountTotal=addMul(amountTotal,itemAmount);
					}
				}
			}
		}
		if(document.getElementById("amountSpan")!=null){
			document.getElementById("amountSpan").innerHTML=amountTotal;
		}
		if(document.getElementById("costSpan")!=null){
			document.getElementById("costSpan").innerHTML=costTotal;
		}
	}
	function selectManager(){
		var url="/base/StafferMainForSelect.ihtm";
		ShowIframe("选择员工",url,800,500,"selectManagerCallBack()");
	}
	function selectManagerCallBack(){
		if(popRetVal!=null){
			var arr=popRetVal.split(";");
			document.getElementById("inBill.managerId").value=arr[0];
			document.getElementById("inBill.managerName").value=arr[1];
		}
	}
	function selectEstablishment(type){
		var url="/base/EstablishmentListForSelect.ihtm?type="+type+"&ts_id=${command.inBill.tallySetId}";
		ShowIframe("供方单位",url,900,500,"selectOffererCallBack()");
	}
	function selectOffererCallBack(){
		if(popRetVal!=null){
			document.getElementById("inBill.offererId").value=popRetVal[0];
			document.getElementById("offererName").value=popRetVal[1];
		}
	}
	function changeTimeSelect(obj,targetName){
		document.getElementById(targetName).value=obj.value;
	}
	function doOffererTypeChange(){
		document.getElementById("inBill.offererId").value="0";
		document.getElementById("offererName").value="";
	}
	function selectOfferer(){
		var offererType=document.getElementById("inBill.offererType").value;
		if(offererType=='CLIENT' || offererType=='PROVIDER' || offererType=='COOPERATOR'){
			selectEstablishment(offererType);
		}else if(offererType=='DEPARTMENT'){
			var url="/base/DepartmentListForSelect.ihtm";
			ShowIframe("供方单位",url,310,500,"selectOffererCallBack()");
		}else if(offererType=='STOREHOUSE'){
			var url="/base/StorehouseListForSelect.ihtm";
			ShowIframe("供方单位",url,300,300,"selectOffererCallBack()");
		}else if(offererType=='WORK_CENTER'){
			var url="/base/WorkCenterListForSelect.ihtm";
			ShowIframe("供方单位",url,600,400,"selectOffererCallBack()");
		}else{
			ShowAlert('提示框','请选择供方类型',200,100);
		}
	}
	function selectBusinessBill(){
		var url="/make/BusinessBillListForSelect.ihtm?search_type=STO&ts_id=${command.inBill.tallySetId}";
		ShowIframe("选择业务单",url,900,500,"selectBusinessBillCallBack()");
	}
	function selectBusinessBillCallBack(){
		if(popRetVal!=null){
			document.getElementById("inBill.businessBillCode").value=popRetVal[1];
		}
	}
	function doPrint(id){
		showWin(900,600,"/storehouse/InBillPrint.ihtm?id="+id);
	}
	function doOut(id){
		showWin(1024,600,"/storehouse/OutBillNew.ihtm?alert_type=FORM&data_type=IN_BILL&in_bill_id="+id);
	}
	function doInit(){
		showFormErrorMsg();
		resizePopwin();
		if(document.getElementById("pro_code")){
			document.getElementById("pro_code").focus();
		}
	}
	function checkProCode(){
		if(window.event.keyCode==13){
			addProCode();
		}
	}
	function addProCode(){
		var proCode=document.getElementById("pro_code").value.trim();
		if(proCode==""){
			ShowAlert('提示框','请输入条形码',200,100);
		}else{
			document.getElementById("LoadProcess").style.top=getTopPos(document.getElementById("pro_code"))+50+"px";
			document.getElementById("LoadProcess").style.left=getleftPos(document.getElementById("pro_code"))+100+"px";
			document.getElementById("LoadProcess").style.display="";
			var xmlHttp=createXMLHttpRequest();
			var url="/base/GetProduct.ihtm?pro_code="+encodeURIComponent(proCode);
			xmlHttp.open("GET", url, true);
			xmlHttp.onreadystatechange = function(){
				if (xmlHttp.readyState == 4) {
		      		if (xmlHttp.status == 200) {
		      			var xml=xmlHttp.responseXML;
		      			var id=getNodeValue(xml.getElementsByTagName("pro_id")[0]);
						var code=getNodeValue(xml.getElementsByTagName("pro_code")[0]);
						var name=getNodeValue(xml.getElementsByTagName("pro_name")[0]);
						var unit=getNodeValue(xml.getElementsByTagName("unit")[0]);
		      			
		      			if(id!="0"){
		      				var found=false;
		      				var itemNum=document.getElementById("item_num").value-0;
							for(var i=0;i<itemNum;i++){
								if(document.getElementById("status_"+i).value!="DELETE"){
									if(document.getElementById("product_code_"+i).value==code){
										var amount=document.getElementById("amount_"+i).value;
										if(!isNaN(amount)){
											amount=amount-0+1;
										}else{
											amount=1;
										}
										document.getElementById("amount_"+i).value=amount;
										checkItemChange(i);
										found=true;
										break;
									}
								}
							}
							if(!found){
								var newIndex=doItemAdd();
								document.getElementById("product_id_"+newIndex).value=id;
								document.getElementById("product_code_"+newIndex).value=code;
								document.getElementById("product_name_"+newIndex).value=name;
								document.getElementById("product_unit_"+newIndex).value=unit;
								document.getElementById("amount_"+newIndex).value="1";
								checkItemChange(newIndex);
							}
		      			}
		      			
		      			document.getElementById("LoadProcess").style.display="none";
		      		}
		      	}
	      	};
	      	xmlHttp.send(null);
	      	document.getElementById("pro_code").value="";
		}
	}
	function getNodeValue(node){
		if(node.firstChild!=null){
			return node.firstChild.data;
		}else{
			return "";
		}
	}

	function doUpload(){
		var storehouseId = document.getElementById("inBill.storehouseId").value;
		if(storehouseId=="" || storehouseId=="0"){
			ShowAlert('提示框','请选择仓库',200,100);
		}else{
			ShowIframe("导入Excel","/storehouse/InBillUploadForm.ihtm?storehouse_id="+storehouseId,560,300,"doUploadCallBack()");
		}
	}
	function doUploadCallBack(){
		if(popRetVal){
			document.getElementById("LoadProcess").style.top=getTopPos(document.getElementById("uplo_link"))+50+"px";
			document.getElementById("LoadProcess").style.left=getleftPos(document.getElementById("uplo_link"))+100+"px";
			document.getElementById("LoadProcess").style.display="";

			var fileName = popRetVal;
			var url="/storehouse/ImportInBillItem.ihtm?file_name=" + encodeURIComponent(fileName);
			var xmlHttp=createXMLHttpRequest();
			xmlHttp.open("GET", url, true);
			xmlHttp.onreadystatechange = function(){
				if (xmlHttp.readyState == 4) {
		      		if (xmlHttp.status == 200) {
			      		var xml = xmlHttp.responseXML;
			      		var body = xml.getElementsByTagName("body")[0];
			      		// 获取错误提示信息
			      		var alertMsg = body.getElementsByTagName("alert_msg")[0];
			      		if(alertMsg){
			      			document.getElementById("LoadProcess").style.display="none";
			      			ShowAlert('提示框',getNodeValue(alertMsg),200,100);
			      		}else{
			      			// 没有错误信息则继续
				      		var infoList = body.getElementsByTagName("pro");
				      		for(var i=0; i<infoList.length; i++){
				      			var newIndex=doItemAdd();
								document.getElementById("product_id_"+newIndex).value=getNodeValue(infoList[i].getElementsByTagName("pro_id")[0]);
								document.getElementById("product_code_"+newIndex).value=getNodeValue(infoList[i].getElementsByTagName("pro_code")[0]);
								document.getElementById("product_name_"+newIndex).value=getNodeValue(infoList[i].getElementsByTagName("pro_name")[0]);
								document.getElementById("product_unit_"+newIndex).value=getNodeValue(infoList[i].getElementsByTagName("pro_unit")[0]);
								document.getElementById("amount_"+newIndex).value=getNodeValue(infoList[i].getElementsByTagName("pro_amount")[0]);
								document.getElementById("unit_price_"+newIndex).value=getNodeValue(infoList[i].getElementsByTagName("pro_price")[0]);
								document.getElementById("mark_"+newIndex).value=getNodeValue(infoList[i].getElementsByTagName("pro_mark")[0]);
								checkItemChange(newIndex);
				      		}
				      		document.getElementById("LoadProcess").style.display="none";
			      		}
			      		
		      		}
		      	}
		    };
		    xmlHttp.send(null);
	    }
	}
</script>
</head>
<body onload="doInit();">
<div class="Wrap">
	<form name="frm" method="post">
	<div class="Container">
		<div class="Contnet Paper">
			<c:set var="buttonDisabledStr" value="disabled='true'" /><!-- 保存按钮是否可点击 -->
			<c:set var="codeReadOnlyStr" value="" /><!-- 编码框是否可点击 -->
			<c:set var="codeReadOnlyClassStr" value="" /><!-- 编码框颜色 -->
	      	<c:set var="showCost" value="N" />
	      	<c:if test="${command.codeRule.generateRule!='MANUAL'}">
				<c:set var="codeReadOnlyStr" value="readonly='readonly'" />
				<c:set var="codeReadOnlyClassStr" value="disabled" />
			</c:if>
	      	
			<c:if test="${id==null || id==''}">
				<c:set var="pageTopTitle" value="新增入库单" />
				<c:set var="buttonDisabledStr" value="" />
			</c:if>
			<c:if test="${id!=null && id!=''}">
				<c:set var="pageTopTitle" value="编辑入库单" />
				<c:if test="${command.inBill.enabled=='Y' && command.inBill.examined=='N'}">
					<c:if test="${currentUser.user.userType==1 || fn:indexOf(currentUser.privs,';IN_BILL;')!=-1}">
						<c:set var="buttonDisabledStr" value="" /><!-- 未审核时有权限就可以修改 -->
					</c:if>
				</c:if>
			</c:if>
			<c:if test="${id==null || id=='' || currentUser.user.userType==1 || fn:indexOf(currentUser.privs,';IN_BILL;')!=-1 || fn:indexOf(currentUser.privs,';STOR_COST;')!=-1}">
				<c:set var="showCost" value="Y" />
			</c:if>
			<c:set var="dateEdit" value="Y" /><!-- 是否可以编辑日期 -->
			<c:if test="${currentUser.user.userType!=1 && fn:indexOf(currentUser.privs,';NO_BILL_DATE;')!=-1}">
				<c:set var="dateEdit" value="N" />
			</c:if>
			
			<!-- 提示信息 -->
			<%@ include file="../inc/BillPageTop.jsp"%>
			
			<!--单 标题-->
			<br>
	        <table class="BillHeading" cellspacing="0" cellpadding="0">
	        	<tr>
		            <td width="301px;" rowspan="2" ><div class="CorpLogo"><img src="${enterpriseInfo.loginImage}" /></div></td>
		            <td width="301px;" rowspan="2" ><h1>${pageTopTitle}</h1></td>
		            <td width="301px;" class="tr vb codeTd">
		                <span class="MustInput">*</span>编号：
		                <spring:bind path="command.inBill.billCode">
				    	<input type="text" class="tbBillCode TextBox ${codeReadOnlyClassStr}" ${codeReadOnlyStr} maxlength="30" onKeyUp="goNextInput('inDateStr');" id="${status.expression}" name="${status.expression}" value="${status.value}">
				    	<script language="javascript">
							setFormErrorMsg('<c:out value="${status.errorMessage}" />',1,'inBill.billCode');
						</script>
			     		</spring:bind>
		            </td>
	        	</tr>
	        	<tr>
	            	<td class="tr" >
	            		<span id="calPosi"></span>
		            	<span class="MustInput">*</span>入库日期：
		            	<spring:bind path="command.inDateStr">
		                    <input type="text" class="tbBillDate_sim TextBox <c:if test="${dateEdit=='N'}">readonly</c:if>" maxlength="15" id="${status.expression}" name="${status.expression}" value="${status.value}" <c:if test="${dateEdit=='N'}">readonly="readonly"</c:if> />
		                    <c:if test="${dateEdit=='Y'}"><img src="/images/calendar.gif" class="imgIconButton" onClick="displayCalendar(document.getElementById('inDateStr'),'yyyy-mm-dd',document.getElementById('calPosi'));"></c:if>
		                    <script language="javascript">
						    	setFormErrorMsg('<c:out value="${status.errorMessage}" />',2,'inDateStr');
						    </script>
		                </spring:bind>
	            	</td>
	        	</tr>
	        </table>
			
			<!-- 单 头信息 -->
	        <div class="TopBottom_Border">
	        	<table class="BillHeadInfo" cellspacing="0" cellpadding="0">
	        		<tr>
	            		<td width="284px">
	                		<span class="MustInput">*</span>仓库：
	                		<spring:bind path="command.inBill.storehouseId">
	                    	<select style="width:174px" id="${status.expression}" name="${status.expression}">
								<option value="0">==请选择==</option>
								<c:forEach var="item" items="${storehouseList}">
									<c:if test="${item.enabled=='Y' && (enterpriseInfo.storTs=='Y' && item.tallySetId==command.inBill.tallySetId || enterpriseInfo.storTs=='N') || item.id==status.value}"><option value="${item.id}" <c:if test="${status.value==item.id}">selected</c:if>>${item.stoName}</option></c:if>
								</c:forEach>
			  				</select>
				          	<script language="javascript">
				          		setFormErrorMsg('<c:out value="${status.errorMessage}" />',3);
				          	</script>
	                		</spring:bind>
	            		</td>
	            		<th width="84px">供方类型：</th>
	            		<td width="313px">
	            			<spring:bind path="command.inBill.offererType">
	                		<select style="width:100px" id="${status.expression}" name="${status.expression}" onchange="doOffererTypeChange();">
								<option value="">==请选择==</option>
								<option value="WORK_CENTER" <c:if test="${status.value=='WORK_CENTER'}">selected</c:if>>工作中心</option>
								<option value="PROVIDER" <c:if test="${status.value=='PROVIDER'}">selected</c:if>>供应商</option>
								<option value="COOPERATOR" <c:if test="${status.value=='COOPERATOR'}">selected</c:if>>外协商</option>
								<option value="DEPARTMENT" <c:if test="${status.value=='DEPARTMENT'}">selected</c:if>>部门</option>
								<option value="STOREHOUSE" <c:if test="${status.value=='STOREHOUSE'}">selected</c:if>>仓库</option>
								<option value="CLIENT" <c:if test="${status.value=='CLIENT'}">selected</c:if>>客户</option>
					  		</select>
					        <script language="javascript">
					          	setFormErrorMsg('<c:out value="${status.errorMessage}" />',6);
					        </script>
					        </spring:bind>
					        供方：
	                		<spring:bind path="command.offererName">
	                		<input type="text" class="TextBox readonly" readonly="readonly" style="width:104px" id="${status.expression}" name="${status.expression}" value="${status.value}">
							<img class="make-a" src="/images/make-a.gif" style="cursor:pointer;" onClick="selectOfferer();">
							</spring:bind>
							<spring:bind path="command.inBill.offererId">
							<input type="hidden" id="${status.expression}" name="${status.expression}" value="${status.value}">
	                    	<script language="javascript">
						    	setFormErrorMsg('<c:out value="${status.errorMessage}" />',7);
						    </script>
	                		</spring:bind>
	            		</td>
	            		<td width="223px;" class="tr">
	            			<span class="MustInput">*</span>入库类型：
	                		<spring:bind path="command.inBill.inTypeId">
	                    	<select style="width:110px" id="${status.expression}" name="${status.expression}">
								<option value="0">==请选择==</option>
								<c:forEach var="item" items="${inTypeList}">
									<c:if test="${item.enabled=='Y' || item.id==status.value}"><option value="${item.id}" <c:if test="${status.value==item.id}">selected</c:if>>${item.typeName}</option></c:if>
								</c:forEach>
				  			</select>
					        <script language="javascript">
					        	setFormErrorMsg('<c:out value="${status.errorMessage}" />',4);
					        </script>
	                		</spring:bind>
	            		</td>
	        		</tr>
	        	</table>
	        </div>
			
			<!-- 明细 -->
	        <input type="hidden" id="item_num" name="item_num" value="${fn:length(command.items)}">
	        <table id="BillDetails" class="BillDetails" width="100%" cellspacing="0" cellpadding="0">
	        	<tbody id="itemRowTbl">
				<tr>
					<th width="12%">材料编号</th>
					<th width="25%">品名规格</th>
					<th width="8%">单位</th>
					<th width="10%">数量</th>
					<th width="10%">单价(元)</th>
					<th width="10%">金额(元)</th>
					<th width="20%">备注</th>
					<th width="5%">操作</th>
				</tr>
				<c:forEach var="item" items="${command.items}" varStatus="i">
				<tr id="itemTr${i.index}" <c:if test="${item.status=='DELETE'}">style="display:none"</c:if>>
					<td>
						<input type="text" class="TextBox readonly" readonly="readonly" style="width:80px" id="product_code_${i.index}" name="product_code_${i.index}" value="${item.productCode}">
					</td>
					<td>
						<input type="text" class="TextBox readonly" readonly="readonly" style="width:160px" id="product_name_${i.index}" name="product_name_${i.index}" value="<c:out value="${item.productName}" />" onmouseover="this.title=this.value">
						<img src="/images/icon_add.gif" style="cursor:pointer;" onClick="selectProduct(${i.index},'');" >
						<input type="hidden" id="product_id_${i.index}" name="product_id_${i.index}" value="${item.inBillItem.productId}">
					</td>
					<td>
						<input type="text" class="TextBox readonly" readonly="readonly" style="width:40px" id="product_unit_${i.index}" name="product_unit_${i.index}" value="${item.unit}">
					</td>
					<td>
						<input type="text" class="TextBox" style="width:50px;text-align:right;"  maxlength="10" id="amount_${i.index}" name="amount_${i.index}" value="${item.amountStr}" onChange="checkItemChange(${i.index},this.id);">
					</td>
					<td>
						<c:if test="${showCost=='Y'}">
						<input type="text" class="TextBox" style="width:50px;text-align:right;" maxlength="10" id="unit_price_${i.index}" name="unit_price_${i.index}" value="${item.unitPriceStr}" onChange="checkItemChange(${i.index},this.id);">
						</c:if>
					</td>
					<td>
						<c:if test="${showCost=='Y'}">
						<input class="TextBox readonly" readonly="readonly" type="text" style="width:50px;text-align:right;" maxlength="10" id="cost_${i.index}" name="cost_${i.index}" value='<commonTag:parseBigDecimal source="${item.inBillItem.cost}" />'>
						</c:if>
					</td>
					<td>
						<input type="text" class="TextBox" style="width:150px" maxlength="200" id="mark_${i.index}" name="mark_${i.index}" value="${item.inBillItem.mark}" onChange="checkItemChange(${i.index},this.id);">
					</td>
					<td>
						<a href="javascript:doItemDelete(${i.index});">删除</a>
						<input type="hidden" id="status_${i.index}" name="status_${i.index}" value="${item.status}">
						<input type="hidden" id="id_${i.index}" name="id_${i.index}" value="${item.oldId}">
					</td>
				</tr>
				</c:forEach>
				</tbody>
			</table>
			<div class="table-bot" style="margin-top:4px">
				<span style="float:right;PADDING-RIGHT:10px;color:#aaa">
					数量小计：<span id="amountSpan"><commonTag:parseBigDecimal source="${command.amount}" /></span>&nbsp;
					<c:if test="${showCost=='Y'}">
						金额小计：<span id="costSpan"><commonTag:parseBigDecimal source="${command.cost}" /></span>元
					</c:if>
				 </span>
				<c:if test="${buttonDisabledStr==''}">
					请输入条形码：
					<input type="text" class="TextBox" style="width:120px" id="pro_code" name="pro_code" onKeyUp="checkProCode();" title="材料编号作为材料的条形码，可以在这里直接扫描出入库">
					<input type="button" style="font-size:12px;" value="加入" onClick="addProCode();">
					<a href="javascript:doMultiSelect();">增加入库明细</a>
					<span style="color:#aaa">（点击这里添加入库的材料）</span>
					<a id="uplo_link" href="javascript:doUpload();">从Excel导入</a>
				</c:if>
			</div>					      
			<br>
			<spring:bind path="command.items">
	          	<script language="javascript">
	          		setFormErrorMsg('<c:out value="${status.errorMessage}" />',8);
	          	</script>
      		</spring:bind>
			
			<!-- 附加信息 -->
	        <div class="TopBottom_Border">
	        	<table class="BillElseInfo" cellspacing="0" cellpadding="0">
	        		<tr>
	            		<th width="84px"><span class="MustInput">*</span>经办人：</th>
	            		<td width="200px">
	            			<spring:bind path="command.inBill.managerName">
							<input type="text" class="tbInfo1 TextBox readonly" readonly="readonly" id="${status.expression}" name="${status.expression}" value="${status.value}">
							<img class="make-a" src="/images/make-a.gif" style="cursor:pointer;" onClick="selectManager();">
					      	</spring:bind>
					      	<spring:bind path="command.inBill.managerId">
							<input type="hidden" id="${status.expression}" name="${status.expression}" value="${status.value}">
						    <script language="javascript">
						    	setFormErrorMsg('<c:out value="${status.errorMessage}" />',8);
						    </script>
							</spring:bind>
	            		</td>
	            		<th width="84px">备注：</th>
	            		<spring:bind path="command.inBill.mark">
	            		<td width="273px">
	            			<input type="text" class="tbInfo2 TextBox" maxlength="50" id="${status.expression}" name="${status.expression}" value="${status.value}">
				          	<script language="javascript">
				          		setFormErrorMsg('<c:out value="${status.errorMessage}" />',10,'inBill.mark');
				          	</script>
	            		</td>
	            		</spring:bind>
	            		<th width="84px">&nbsp;</th>
            			<td width="179px">&nbsp;</td>
	        		</tr>
	        	</table>
	        </div>
	        <br>
	        <div class="BillNotes">
                <span>开单人：${command.inBill.createrName} <c:if test="${command.inBill.createTime!=null}"><fmt:formatDate value="${command.inBill.createTime}" pattern="yyyy-MM-dd HH:mm"/></c:if></span>
        		<span>审核人：<c:if test="${command.inBill.examinerId!=0}">${command.inBill.examinerName} <c:if test="${command.inBill.examineTime!=null}"><fmt:formatDate value="${command.inBill.examineTime}" pattern="yyyy-MM-dd HH:mm"/></c:if></c:if></span>
				<span>单据帐套：${command.tallySetName}</span>
				<spring:bind path="command.inBill.tallySetId">
			    	<script language="javascript">
			          	setFormErrorMsg('<c:out value="${status.errorMessage}" />',1);
			    	</script>
				</spring:bind>
			</div>
		</div>
		
		<!-- 底栏按钮 -->
		<div class="Footer">
			<div id="buttonDiv">
				<input type="button" class="buttom-a" value=" 保 存 " onClick="doSave('0');" ${buttonDisabledStr}>
				<c:if test="${id==null || id==''}">
					<input type="button" class="buttom-a" value="保存并新增" onClick="doSave('1');" ${buttonDisabledStr}>
					<input type="button" class="buttom-a" value="保存并复制" onClick="doSave('2');" ${buttonDisabledStr}>
				</c:if>
				<c:if test="${id!=null && id!=''}">
					<input type="button" class="buttom-a" value="复制新增" onClick="doReorder(${id});" title="把当前入库单复制生成新的入库单" <c:if test="${command.inBill.enabled=='N'}">disabled='true'</c:if>>
					<!--
					<c:if test="${currentUser.user.userType==1 || fn:indexOf(currentUser.privs,';OUT_BILL;')!=-1}">
					<input type="button" class="buttom-a" value="生成出库单" onClick="doOut(${id});" <c:if test="${command.inBill.enabled=='N'}">disabled='true'</c:if>>
					</c:if>
					-->
					<input type="button" class="buttom-a" value=" 打 印 " onClick="doPrint(${id});" <c:if test="${command.inBill.enabled=='N'}">disabled='true'</c:if>>
				</c:if>
				<input type="button" class="buttom-a" value=" 取 消 " onClick="doCancel();">
				<input type="hidden" name="continue_flag" id="continue_flag" value="0">
				<input type="hidden" id="examine" name="examine" value="0">
				<spring:bind path="command.sychronizeValue"><input type="hidden" id="${status.expression}" name="${status.expression}" value="${status.value}"></spring:bind>
				<spring:bind path="command.inDateHour"><input type="hidden" id="${status.expression}" name="${status.expression}" value="${status.value}"></spring:bind>
				<spring:bind path="command.inDateMinute"><input type="hidden" id="${status.expression}" name="${status.expression}" value="${status.value}"></spring:bind>
			</div>
			<div id="waitDiv" style="display:none">
    			<span>请稍候...</span>
			</div>
		</div>
		
	</div>
	</form>
</div>
<%@ include file="../inc/LoadingDiv.jsp"%>
</body>
</html>
